PSA Object Model Diagrams

MultiCurrencyService

global with sharing class MultiCurrencyService

this service provides the functionality to handle exchanges between multiple currencies in psa.

Methods

useDatedExchangeRates

global static Boolean useDatedExchangeRates()

Indicates if dated exchange rates are used for multi-currency conversions when PSA is configured to use currencies specified in the Currencies tab.

Return Value

A Boolean indicating whether or not dated exchange rates are being used.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

useSalesforceAdvancedMultiCurrency

global static Boolean useSalesforceAdvancedMultiCurrency()

When set to true, PSA uses the Salesforce advanced multi-currency feature. When set to false, PSA uses the currencies defined in the Currencies tab.

Return Value

A Boolean indicating if PSA uses Salesforce Advanced Multi-Currency.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

getConvertedAmount

global static Double getConvertedAmount(Double fromAmount, String fromCurrency, String toCurrency, Date d)

Convert amount A of currency X to currency Y as of date D.

Input Parameters

Name Type Description
fromAmount Double The Decimal amount in the currency from which the conversion is to be made.
fromCurrency String The String currency code from which the conversion is to be made.
toCurrency String The String currency code to which the conversion is to be made.
d Date The Date for which the currency exchange is to be made.

Return Value

A Double representing the resulting amount of the currency conversion.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

getConversionRatesByDate

global static Map<Date, Map<String, Decimal>> getConversionRatesByDate(List<String> currencyCodeList, List<Date> dateList)

Use a list of currency codes and a list of dates to get a map of dated currency codes to conversion rates.

Input Parameters

Name Type Description
currencyCodeList List<String> A List of String currency codes for which to get Decimal conversion rates.
dateList List<Date> A List of Dates for which to get Decimal conversion rates.

Return Value

A Map of conversion Date to a Map of String currency codes to Decimal conversion rate.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

getConversionRatesByDate

global static Map<Date, Map<String, Decimal>> getConversionRatesByDate(Set<String> currencyCodeSet, List<Date> dateList)

Use a set of currency codes and a list of dates to get a map of dated currency codes to conversion rates.

Input Parameters

Name Type Description
currencyCodeSet Set<String> A Set of String currency codes for which to get conversion rates.
dateList List<Date> A List of Dates for which to get conversion rates.

Return Value

A Map of conversion Date to a Map of String currency code to Decimal conversion rates.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

getConversionRatesByDate

global static Map<Date, Map<String, Decimal>> getConversionRatesByDate(List<String> currencyCodeList, Set<Date> dateSet)

Use a list of currency codes and a set of dates to get a map of dated currency codes to conversion rates.

Input Parameters

Name Type Description
currencyCodeList List<String> A List of String currency codes for which to get conversion rates.
dateSet Set<Date> A Set of Dates for which to get conversion rates.

Return Value

A Map of conversion Date to a Map of String currency code to Decimal conversion rate.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

getConversionRatesByDate

global static Map<Date, Map<String, Decimal>> getConversionRatesByDate(Set<String> currencyCodeSet, Set<Date> dateSet)

Uses a set of currency codes and a set of dates to get a map of dated currency codes to conversion rates.

Input Parameters

Name Type Description
currencyCodeSet Set<String> A Set of String currency codes for which to get conversion rates.
dateSet Set<Date> A Set of Dates for which to get conversion rates.

Return Value

A Map of conversion Date to a Map of String currency code to Decimal conversion rate.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

getConversionRateRatioByDate

global static Decimal getConversionRateRatioByDate(String fromCurrencyCode, String toCurrencyCode, Date initialConversionDate, Date targetConversionDate)

Get a decimal conversion rate ratio to convert one converted amount of currency A on conversion date X to currency B on conversion date Y.

Input Parameters

Name Type Description
fromCurrencyCode String The String currency code from which the conversion is coming.
toCurrencyCode String The String currency code to which the conversion is targeting.
initialConversionDate Date The Date on which the exchange rate converted amount occurred.
targetConversionDate Date The Date for which you want the converted amount modified to reflect.

Return Value

A Decimal conversion rate ratio that can be used to modify a Decimal converted currency amount on on initial Date to another Date.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

isCurrencyCorporate

global static Map<String, Boolean> isCurrencyCorporate(Set<String> currencyCodeSet)

Uses a set of currency codes to return a map of currency codes and associated Booleans indicating if the currency code is corporate.

Input Parameters

Name Type Description
currencyCodeSet Set<String> A Set of Strings representing the currencies to check.

Return Value

A Map of String currency codes to Boolean indicating whether the currency is the corporate one.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

MultiCurrencyService.ExchangeRate

global with sharing class ExchangeRate

exchangerate provides a multi-currency helper class

Properties

Name Type Description
currentScale Integer the scale of precision to use when converting currencies. see system.decimal.divide(). @return An Integer representing the number of decimal places of precision.

Methods

ExchangeRate

global ExchangeRate()

Constructor. Creates an empty ExchangeRate.

Return Value

An empty ExchangeRate.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

ExchangeRate

global ExchangeRate(Set<String> currencyCodeSet, Set<Date> dateSet)

Constructor. Using a set of currency codes and a set of dates, creates an ExchangeRate for all combinations of these currencies and dates.

Input Parameters

Name Type Description
currencyCodeSet Set<String> A Set of String currency codes for which to load rates.
dateSet Set<Date> A Set of Dates for which to load the given currency code rates.

Return Value

An ExchangeRate with permutations for all currencies and dates provided.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

ExchangeRate

global ExchangeRate(Set<String> currencyCodeSet, Set<Date> dateSet, Integer scale)

Constructor. Using a set of currency codes and a set of dates, creates an ExchangeRate for all combinations of these currencies and dates for the given precision scale.

Input Parameters

Name Type Description
currencyCodeSet Set<String> A Set of String currency codes for which to load rates.
dateSet Set<Date> A Set of Dates for which to load the given currency code rates.
scale Integer An Integer number representing the number of decimal places of precision.

Return Value

An ExchangeRate with permutations for all currencies and dates provided of given scale precision.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

addDatedCurrency

global void addDatedCurrency(String currencyCode, Date conversionDate)

Adds a dated currency for given currency on given date.

Input Parameters

Name Type Description
currencyCode String A String indicating a currency code to add.
conversionDate Date A Date on which to add the given currency code.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

getDatedRate

global Decimal getDatedRate(String currencyCode, Date rateDate)

Get the exchange rate for a given currency on a given date.

Input Parameters

Name Type Description
currencyCode String A String representing the currency code for the exchange rate desired.
rateDate Date A Date on which the exchange rate for given currency is desired.

Return Value

A Decimal representing the exchange rate for given currency on given date.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code

convertAmount

global Decimal convertAmount(Decimal fromAmount, String fromCurrencyCode, Date fromDate, String toCurrencyCode, Date toDate)

Convert amount A1 from currency C1 on date D1 to currency C2 on date D2.

Input Parameters

Name Type Description
fromAmount Decimal A decimal representing the amount in the source currency.
fromCurrencyCode String A String representing the currency code of the source currency.
fromDate Date The Date on which the fromCurrency is being considered for the conversion.
toCurrencyCode String A String representing the currency code of the destination currency.
toDate Date The Date on which the toCurrency is being considered for the conversion.

Return Value

A Decimal representing the converted amount in the given toCurrencyCode.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

You need to provide some sample code
© Copyright 2009–2021 FinancialForce.com, inc. Confidential – all rights reserved. Various trademarks held by their respective owners.